package com.huitone.gddw.service.impl.worktable;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.huitone.gddw.dao.entity.NetSwtich;
import com.huitone.gddw.dao.worktable.INetSwtichDao;
import com.huitone.gddw.model.support.QueryPage;
import com.huitone.gddw.service.INetSwtichService;
import com.huitone.gddw.service.dto.NetSwtichDTO;

/**
 * 短信平台切换接口实现类
 * @author wuluodan
 *
 */
@Service
public class NetSwtichService implements INetSwtichService {

	@Autowired
	private INetSwtichDao netSwtichDao;
	
	

	@Override
	public Integer changeTerrace(String runType) {
			return netSwtichDao.updateAllTerrace(runType);
	}

	@Override
	public List<NetSwtichDTO> selectNetByIdOrName(Map<String, Object> map) {
		return netSwtichDao.selectNetByIdOrName(map);
	}

	@Override
	public QueryPage<NetSwtichDTO> findTerracePage(QueryPage<NetSwtich> page) {
		Map<String, Object> map = page.getParams();
		QueryPage<NetSwtichDTO> queryPage = new QueryPage<NetSwtichDTO>();
		map.put("start", (page.getPageNo() - 1) * page.getPageSize() + 1);
		map.put("end", page.getPageNo() * page.getPageSize());
		List<NetSwtichDTO> result = this.selectNetByIdOrName(map);
		int totalCount = this.selectCount(map);
		
		queryPage.setResult(result);
		queryPage.setPageNo(page.getPageNo());
		queryPage.setPageSize(page.getPageSize());
		queryPage.setTotalCount(totalCount);
		return queryPage;
	}

	@Override
	public int selectCount(Map<String, Object> map) {
		return netSwtichDao.selectCount(map);
	}

	@Override
	public String selectStatus() {
		return netSwtichDao.selectPage();
	}

	 

}
